package com.lianzhihui.romeex.mvp.model;

import android.content.Context;

import com.blankj.utilcode.util.ToastUtils;
import com.lianzhihui.romeex.bean.MyTeamBean;
import com.lianzhihui.romeex.net.APIConstant;
import com.lianzhihui.romeex.net.HttpManager;
import com.lianzhihui.romeex.net.HttpManagerCallback;
import com.lianzhihui.romeex.net.ResultData;
import com.lianzhihui.romeex.utils.GsonUtil;
import com.lianzhihui.romeex.utils.LogUtil;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.HttpParams;

/**
 * @ProjectName: romeex
 * @Package: com.lianzhihui.romeex.mvp.model.base
 * @ClassName: InvitationModellmp
 * @Description: java类作用描述
 * @Author: zhanghong
 * @CreateDate: 2020/11/9 18:18
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/11/9 18:18
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class MyTeamModelImp {


    private Context context;
    MyTeamModelInterface model;

    public MyTeamModelImp(Context context, MyTeamModelInterface model) {
        this.context = context;
        this.model = model;
    }

    /**
     * 用户团队邀请首页
     */
    public void requestSunFindsunrelation() {
        HttpParams params = new HttpParams();
        new HttpManager(context, new HttpManagerCallback() {
            @Override
            public void onSuccess(ResultData o) {
                LogUtil.info("InvitationModelImp:", o.getCode() + "");
                if (o.getCode() == 200) {
                    MyTeamBean bean = GsonUtil.GsonToBean(o.getData(), MyTeamBean.class);

                    model.responseFindSunRelationSuccess(bean);
                } else {
                    model.onFailure();
                }
            }

            @Override
            public void onError(ApiException e) {
                    ToastUtils.showShort(e.getMessage());

                model.onFailure();
            }
        }).post(APIConstant.SUN_FINDSUNRELATION, params);
    }

}
